# 测试报告
import os
import time
import unittest

import HTMLTestRunner


# 测试报告 path=报告路径  mode=执行文件查找方法
def report(path,mode):
    report_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'report')
    html_file = time.strftime('%Y%m%d%H%M%S') + 'HTMLreport.html'
    html_report_path = os.path.join(report_path, html_file)
    loader = unittest.defaultTestLoader.discover(path, mode)
    with open(html_report_path, 'wb') as f:
        runner = HTMLTestRunner.HTMLTestRunner(
            tester='年入百万',
            title='测试报告',
            description='测试描述',
            stream=f,
            verbosity=2
        )
        runner.run(loader)


if __name__ == '__main__':
    report('case','test_order_generation.py')
